package com.itheima.mapper;

import com.itheima.pojo.ShoppingCart;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 加入购物车
     */
    @Insert("insert into shoppingcart values (#{id},#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    int addShoppingCart(ShoppingCart shoppingCart);

    /**
     * 购物车列表
     */
    @Select("select * from shoppingcart")
    List<ShoppingCart> selectshoppingcart();

    /**
     * 清空购物车
     */
    @Delete("delete from shoppingcart ")
    int cleanshoppingCart();

    /**
     * 删除购物车商品
     */

    int deleteshoppingCart(ShoppingCart shoppingCart);


    /**
     * 根据菜品id 套餐id 获取购物车对象
     */

    ShoppingCart selectShoppingCartByDishId(ShoppingCart shoppingCart);

    /**
     * 修改购物车数量
     */
    int updeteNumber(ShoppingCart shoppingCart);


    /**
     * 根据购物车id获取到对应的用户对象
     */
    @Select("select * from user where user.id= shoppingcart.userId")
    User selectShoppingCartById();
}
